/**
 * 
 */
package org.jinion.util;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * This list start index is 1, 2...
 * @author zhlmmc
 *
 */
public class DataList<T> {
	private LinkedList<T> list;
	
	public DataList(){
		list = new LinkedList<T>();
	}
	
	public void add(T obj){
		list.add(obj);
	}
	
	public Iterator<T> iterator(){
		return this.list.iterator();
	}
	
	public int size(){
		return this.list.size();
	}
	
	/**
	 * Index starts from 1, 2...
	 * @param index
	 * @return
	 */
	public T get(int index) {
		if (index < 1) {
			throw new IndexOutOfBoundsException("DataList index starts from 1!");
		}
		
		return this.list.get(index - 1);
	}
}
